Skip to content

Fix union type parameter inference - #5895

Merged
Anders Hejlsberg (ahejlsberg) merged 4 commits into
masterfrom
unionTypeParameterInference
Dec 3, 2015
Merged

Fix union type parameter inference#5895
Anders Hejlsberg (ahejlsberg) merged 4 commits into
masterfrom
unionTypeParameterInference

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #5861.

@ahejlsberg

Copy link
Copy Markdown
Member Author

A bit more context on the fix. We previously would consider two type parameters identical if they were different type parameters but had identical constraints (but, oddly, wouldn't consider them assignable to each other). This of course isn't right, but it sort of worked when we were comparing constraints in generic signatures which was really the only time it would come up. However, we now sometimes need to compare type parameters for identity during union and intersection type inference (because of #5738) and we want different type parameters to actually be considered different, so we have to remove this logic. The effect is that we won't check whether type parameter constraints are identical when comparing generic signatures, as explained here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remove the error comment

@sandersn

Copy link
Copy Markdown
Member

Could you also add a test for the case that type parameter constraints are not identical, but we don't check? It would be good to have as documentation in case do we go back and decide to start checking.

@sandersn

Copy link
Copy Markdown
Member

👍

Anders Hejlsberg (ahejlsberg) added a commit that referenced this pull request Dec 3, 2015
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the unionTypeParameterInference branch December 3, 2015 20:23
Anders Hejlsberg (ahejlsberg) added a commit that referenced this pull request Dec 3, 2015
Fix union type parameter inference
Conflicts:
	src/compiler/checker.ts
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants